package com.rivulet.doj_backend.mapper;

import com.rivulet.doj_backend.pojo.Class;
import com.rivulet.doj_backend.pojo.Question;
import org.apache.ibatis.annotations.Delete;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;
import org.springframework.stereotype.Component;

@Component
public interface ClassMapper {
    @Select("select * from t_class where class_id = #{class_id}")
    public Class showClass(@Param("class_id")Integer class_id);

    @Insert("insert into r_user_join_class (user_id,class_id) values (#{user_id},#{class_id})")
    public void setUserJoinClass(@Param("user_id")Integer user_id,@Param("class_id")Integer class_id);

    @Select("select class_id from r_user_join_class where user_id = #{user_id}")
    public Integer getClassIdByUserId(@Param("user_id")Integer user_id);

    @Delete("delete from t_class where class_id = #{class_id}")
    public void delClass(@Param("class_id")Integer class_id);

    @Select("select class_task_id from r_user_to_class_task where user_id = #{user_id}")
    public Integer showTask(@Param("user_id")Integer user_id);

    @Delete("delete  from r_user_join_class where class_id = #{class_id} && user_id = #{user_id}")
    public void delUser(@Param("user_id")Integer user_id,@Param("class_id")Integer class_id);

    @Insert({"insert  t_class_task (task_id,question_number,question_ids,question_score,task_explain,relation_class_id) values (#{task_id},#{question_number},#{question_ids},#{question_score},#{task_explain},#{relation_class_id})"})
    void addTask(@Param("task_id") Integer var1, @Param("question_number") Integer var2, @Param("question_ids") int var3, @Param("question_score") Integer var4, @Param("task_explain") String var5, @Param("relation_class_id") Integer var6);

    @Insert({"insert r_user_to_class_task (user_id,class_task_id) value (#{user_id},#{class_task_id})"})
    void addTask2(@Param("user_id") Integer var1, @Param("task_id") Integer var2);

    @Insert({"insert t_class (class_id,class_root,task_number,user_number,creat_time,class_level) value (#{class_id},#{class_root},#{task_number},#{user_number},#{creat_time},#{class_level})"})
    void addClass(@Param("user_id") Integer var1, @Param("class_id") Integer var2, @Param("class_root") String var3, @Param("task_number") Integer var4, @Param("user_number") Integer var5, @Param("creat_time") Integer var6, @Param("class_level") Integer var7);

    @Insert({"insert r_user_to_class_task (user_id,class_id) value (#{user_id},#{class_id})"})
    void addClass2(@Param("user_id") Integer var1, @Param("class_id") Integer var2);

    @Select({"select user_number from t_class where class_id = #{class_id}"})
    Integer getPeopleNumber(@Param("class_id") Integer var1);

}
